package com.wicket.okroperation.biz.service.nb;

import cn.hutool.core.bean.BeanUtil;
import com.wicket.okroperation.biz.service.dto.common.DynamicLookupDataDto;
import com.wicket.okroperation.common.annotations.TreeType;
import com.wicket.okroperation.common.util.CommonFunctionHelper;
import org.apache.skywalking.apm.toolkit.trace.Tag;
import org.apache.skywalking.apm.toolkit.trace.Tags;
import org.apache.skywalking.apm.toolkit.trace.Trace;
import org.springframework.stereotype.Service;
import com.wicket.okroperation.biz.service.dto.req.AddClusterEsExecutionScriptReqDto;
import com.wicket.okroperation.biz.service.dto.res.AddClusterEsExecutionScriptRespDto;
import com.wicket.okroperation.biz.service.dto.req.AddEsExecutionScriptReqDto;
import com.wicket.okroperation.biz.service.dto.res.AddEsExecutionScriptRespDto;
import com.wicket.okroperation.biz.service.dto.req.AddClusterNacosExecutionScriptReqDto;
import com.wicket.okroperation.biz.service.dto.res.AddClusterNacosExecutionScriptRespDto;
import com.wicket.okroperation.biz.service.dto.req.AddApolloExecutionScriptReqDto;
import com.wicket.okroperation.biz.service.dto.res.AddApolloExecutionScriptRespDto;
import com.wicket.okroperation.biz.service.dto.req.AddSkywalkingExecutionScriptReqDto;
import com.wicket.okroperation.biz.service.dto.res.AddSkywalkingExecutionScriptRespDto;
import com.wicket.okroperation.biz.service.dto.req.AddNgnixExecutionScriptReqDto;
import com.wicket.okroperation.biz.service.dto.res.AddNgnixExecutionScriptRespDto;
import com.wicket.okroperation.biz.service.dto.req.QueryDynamicLookupDataComListReqDto;
import com.wicket.okroperation.biz.service.dto.res.QueryDynamicLookupDataComListRespDto;

import java.lang.reflect.Field;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import com.wicket.okroperation.biz.service.dto.req.BatchDeleteDynamicLookupDeleteDataReqDto;
import com.wicket.okroperation.biz.service.dto.res.BatchDeleteDynamicLookupDeleteDataRespDto;
import com.wicket.okroperation.biz.service.dto.req.QueryAcceptParametersDetailReqDto;
import com.wicket.okroperation.biz.service.dto.res.QueryAcceptParametersDetailRespDto;

/**
 * @author ： 手工接入方法
 * @since 2022/5/28 15:32
 *
 *
 * @version 1.0
 */
@Service
public class NbOperationsDeployment {
/**
      * code:clusterEsModel
      * name:M6新增集群es服务运行脚本（特殊方法）
      * desc:undefined
      * gen by moon at 6/2/2023, 3:08:54 PM
      * 
      **/
     @Trace(operationName = "M6新增集群es服务运行脚本（特殊方法）")
     @Tags({@Tag(key = "参数",value = "arg[0]"),
     @Tag(key = "返回值",value = "returnedObj")})
      public AddClusterEsExecutionScriptRespDto addClusterEsExecutionScript(AddClusterEsExecutionScriptReqDto reqDto) {
       // TODO ruizhe skai dong ; 6/2/2023, 3:08:54 PM
        return new AddClusterEsExecutionScriptRespDto();
      }
/**
      * code:esModel
      * name:M6新增单实例es服务运行脚本（特殊方法）
      * desc:undefined
      * gen by moon at 6/2/2023, 3:09:08 PM
      * 
      **/
     @Trace(operationName = "M6新增单实例es服务运行脚本（特殊方法）")
     @Tags({@Tag(key = "参数",value = "arg[0]"),
     @Tag(key = "返回值",value = "returnedObj")})
      public AddEsExecutionScriptRespDto addEsExecutionScript(AddEsExecutionScriptReqDto reqDto) {
       // TODO ruizhe skai dong ; 6/2/2023, 3:09:08 PM
        return new AddEsExecutionScriptRespDto();
      }
/**
      * code:clusterNacosModel
      * name:M6新增集群nacos服务运行脚本（特殊方法）
      * desc:undefined
      * gen by moon at 6/2/2023, 3:09:20 PM
      * 
      **/
     @Trace(operationName = "M6新增集群nacos服务运行脚本（特殊方法）")
     @Tags({@Tag(key = "参数",value = "arg[0]"),
     @Tag(key = "返回值",value = "returnedObj")})
      public AddClusterNacosExecutionScriptRespDto addClusterNacosExecutionScript(AddClusterNacosExecutionScriptReqDto reqDto) {
       // TODO ruizhe skai dong ; 6/2/2023, 3:09:20 PM
        return new AddClusterNacosExecutionScriptRespDto();
      }
/**
      * code:apolloModel
      * name:M6新增apollo服务运行脚本（特殊方法）
      * desc:undefined
      * gen by moon at 6/2/2023, 3:09:31 PM
      * 
      **/
     @Trace(operationName = "M6新增apollo服务运行脚本（特殊方法）")
     @Tags({@Tag(key = "参数",value = "arg[0]"),
     @Tag(key = "返回值",value = "returnedObj")})
      public AddApolloExecutionScriptRespDto addApolloExecutionScript(AddApolloExecutionScriptReqDto reqDto) {
       // TODO ruizhe skai dong ; 6/2/2023, 3:09:31 PM
        return new AddApolloExecutionScriptRespDto();
      }
/**
      * code:skywalkingModel
      * name:M6新增skywalking服务运行脚本（特殊方法）
      * desc:undefined
      * gen by moon at 6/2/2023, 3:09:43 PM
      * 
      **/
     @Trace(operationName = "M6新增skywalking服务运行脚本（特殊方法）")
     @Tags({@Tag(key = "参数",value = "arg[0]"),
     @Tag(key = "返回值",value = "returnedObj")})
      public AddSkywalkingExecutionScriptRespDto addSkywalkingExecutionScript(AddSkywalkingExecutionScriptReqDto reqDto) {
       // TODO ruizhe skai dong ; 6/2/2023, 3:09:43 PM
        return new AddSkywalkingExecutionScriptRespDto();
      }
/**
      * code:ngnixModel
      * name:M6新增ngnix服务运行脚本（特殊方法）
      * desc:undefined
      * gen by moon at 6/2/2023, 3:10:00 PM
      * 
      **/
     @Trace(operationName = "M6新增ngnix服务运行脚本（特殊方法）")
     @Tags({@Tag(key = "参数",value = "arg[0]"),
     @Tag(key = "返回值",value = "returnedObj")})
      public AddNgnixExecutionScriptRespDto addNgnixExecutionScript(AddNgnixExecutionScriptReqDto reqDto) {
       // TODO ruizhe skai dong ; 6/2/2023, 3:10:00 PM
        return new AddNgnixExecutionScriptRespDto();
      }
/**
      * code:dynamic_lookup_data
      * name:M6查询动态寻表数据列表(特殊方法)
      * desc:undefined
      * gen by moon at 6/11/2023, 3:32:35 AM
      *
      **/
     @Trace(operationName = "M6查询动态寻表数据列表(特殊方法)")
     @Tags({@Tag(key = "参数",value = "arg[0]"),
     @Tag(key = "返回值",value = "returnedObj")})
      public QueryDynamicLookupDataComListRespDto queryDynamicLookupDataComList(QueryDynamicLookupDataComListReqDto reqDto) {
         QueryDynamicLookupDataComListRespDto retData = new QueryDynamicLookupDataComListRespDto();
         Map<String,String> filter = new HashMap<>();
         try {
             Class classzz = reqDto.getClass();
             Field[] declaredFields = classzz.getDeclaredFields();
             for (Field field : declaredFields) {
                 field.setAccessible(true);
                 if (field.get(reqDto)!=null && !field.getName().equals("toolTableEncryptionName")) {
                     String fieldName = com.wicket.okrcomponent.common.util.CommonFunctionHelper.humpToUnderline(field.getName());
                     filter.put(fieldName,(String)field.get(reqDto));
                 }
             }

             if(filter.size()>0){
                 List<Map<String,String>> data = com.wicket.okrcomponent.common.util.CommonFunctionHelper.getDbData(reqDto.getToolTableEncryptionName(),filter);
                 for(Map<String,String> one : data){
                     DynamicLookupDataDto elm = new DynamicLookupDataDto();
                     Class elmClasszz = elm.getClass();
                     Field[] elmDeclaredFields = elmClasszz.getDeclaredFields();
                     for (Field field : elmDeclaredFields) {
                         field.setAccessible(true);
                         String fieldName = com.wicket.okrcomponent.common.util.CommonFunctionHelper.humpToUnderline(field.getName());
                         if(one.containsKey(fieldName)){
                             field.set(elm,one.get(fieldName));
                         }
                     }
                     retData.getDynamicLookupDataList().add(elm);
                 }
             }
         } catch (Exception e) {

         }


         return retData;
      }
/**
      * code:dynamicLookupDeleteData
      * name:M6批量动态寻表删除数据(特殊方法)
      * desc:undefined
      * gen by moon at 9/13/2023, 10:40:26 PM
      * 
      **/
     @Trace(operationName = "M6批量动态寻表删除数据(特殊方法)")
     @Tags({@Tag(key = "参数",value = "arg[0]"),
     @Tag(key = "返回值",value = "returnedObj")})
      public BatchDeleteDynamicLookupDeleteDataRespDto batchDeleteDynamicLookupDeleteData(BatchDeleteDynamicLookupDeleteDataReqDto reqDto) {
         BatchDeleteDynamicLookupDeleteDataRespDto retData = new BatchDeleteDynamicLookupDeleteDataRespDto();
         CommonFunctionHelper.batchDelDbData(reqDto.getToolTableEncryptionName(),reqDto.getDynamicLookupDataList(), CommonFunctionHelper.humpToUnderline(reqDto.getEntityName()));
         return retData;
      }
/**
      * code:receptionService
      * name:M6接收空间列表（特殊方法）
      * desc:undefined
      * gen by moon at 9/13/2023, 10:40:43 PM
      * 
      **/
     @Trace(operationName = "M6接收空间列表（特殊方法）")
     @Tags({@Tag(key = "参数",value = "arg[0]"),
     @Tag(key = "返回值",value = "returnedObj")})
      public QueryAcceptParametersDetailRespDto queryAcceptParametersDetail(QueryAcceptParametersDetailReqDto reqDto) {
         return BeanUtil.toBean(reqDto,QueryAcceptParametersDetailRespDto.class);
      }
  //手工接入方法
}
